#import "ChangePasswordRequest.h"
#import "Utils.h"
#import "SBJson.h"

@implementation ChangePasswordRequest

-(void) makeRequest:(NSDictionary*)infomation
{
	NSDictionary *dictionary = [[NSMutableDictionary alloc]init];
	[dictionary setValue:[Utils getValueForRefKey:kSessionKey] forKey:KSessionKey];
	[dictionary setValue:[infomation valueForKey:kNewPassword] forKey:KNewPassword];
	NSLog(@"%@",[dictionary JSONRepresentation]);
	[super requestTo:@"ChangePassword" withBody:[dictionary JSONRepresentation]];
}

-(void) notifyIfConnectionFail:(NSError*)error
{
	NSLog(@"notifyIfConnectionFail:%@",[error localizedDescription]);
	UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Login Fail" message:@"Connection Error" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
	[alert show];
	[alert release];
}

-(void) processResult:(NSDictionary*)result
{
	//{"LoginResult":{"ErrorMessage":"SUCCESSFUL","isSuccessful":true,"SessionKey":"5d8c379f-a44e-4704-a7f3-b839a110dde5"}}
	NSDictionary *resultDict = [result valueForKey:@"ChangePasswordResult"];
	BOOL rsRet = [[resultDict objectForKey:@"isSuccessful"] boolValue];
	if (_delegate && [_delegate respondsToSelector:@selector(processRequestResult:)]) {
		[_delegate processRequestResult:rsRet];
	}
}

@end
